<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>优惠卷 - {php echo $this->module['config']['sname']}</title>
    {php echo register_jssdk();}
    <meta content="app-id=518966501" name="apple-itunes-app">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=no, maximum-scale=1.0">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <link href="{WELIAM_INDIANA_STATIC}css/common.css" rel="stylesheet">
    <link href="{WELIAM_INDIANA_STATIC}/css/comm.css" rel="stylesheet" type="text/css">
    <link href="{WELIAM_INDIANA_STATIC}/css/member.css" rel="stylesheet" type="text/css">
    <script language="javascript" src="{WELIAM_INDIANA_STATIC}/js/jquery.js"></script>
</head>
<style>
	.lockDiv{width:100%;height:100%;background-color:#000000;position:fixed;top:0px;left:0px;opacity:0.8;z-index: 30;} 
	#moreBtn{position: fixed; top: 0; right: 5px; z-index: 2; padding: 0 10px; line-height: 36px;}
</style>

<body style="zoom: 1; padding-top: 39px;">
	
<div id="checkqrode"></div>
	<!--二维码-->
<div class="alert_box" id="checkalert" style="position: fixed;top:30px;z-index: 10000;left:9%;width: 82%;max-width:530px;background:white;padding: 5% 0 3%;border-radius: 5%;display: none;">
		<img src="{WELIAM_INDIANA_STATIC}image/exit.png" class="exit" id='off' style="width: 10%;float: right;margin-right: -5%;margin-top: -10%;">
		<div style="text-align: center;font-size: 18px;font-weight: 600;">
			扫描二维码核销
		</div>
		<div id="qrcode" style="text-align: center;">
			<img src='http://qr.topscan.com/api.php?w=200&text={$tourl}' style="margin: auto;">
		</div>
		<div style="text-align: center;font-size: 18px;">
				请将二维码出示给店员
		</div>
</div>
<!--二维码-->
	<div class="m-simpleHeader" id="dvHeader">
		<a href="javascript:history.back(-1);" data-pro="back" data-back="true" class="m-simpleHeader-back"><i class="ico ico-back"></i></a>
			<h1>使用优惠卷</h1>
		<a id="moreBtn" href="{php echo $this->createMobileUrl('index')}"><i class="ico ico-home"></i></a>
	</div>
	{if empty($op)}
        <div class="shareCon">
            <dl>
                <dt>将优惠卷<font color="red"><b>"转送给好友"</b></font>，该好友成为您的下线。</dt>
                <dt>点击<font color="red"><b>"自己使用"</b></font>,将弹出的二维码展示给核销工作人员，扫码后为你的账户充值相应的夺宝币。</dt>
                <dt>				
                	<p>★优惠券金额:<span ><font color="red">{$d['discount']}元</font></span></p>
					<p>★订单<font color="red">满{$d['condition']}元</font>可使用</p>
					<p>★有效期至<font color="red">{php echo date('Y',$r['endtime'])}年{php echo date('m',$r['endtime'])}月{php echo date('d',$r['endtime'])}日</font></p>
                </dt>
               转送数量: <div class="w-number" id="pro-view-7">
						<input class="w-number-input" type="tel" id="num" name="num" value="1"  oninput="inputnum()">
							<input type="hidden" id="couponnum"  value="{$r['couponnum']}">
							<a class="w-number-btn w-number-btn-plus" id="up">
								+
							</a>
							<a class="w-number-btn w-number-btn-minus" id="down">
								-
							</a>
						</div>
						<dd onclick="sendto();"><a  class="orangeBtn" style="background: #db3652;">转送给好友</a></dd>
                <!--<dd onclick="$('#m_popUp').show()"><a id="btnShare" href="javascript:;" class="orangeBtn" style="background: #db3652;">转送给好友</a></dd>-->
                 <dd  id="check"><a href="javascript:;" class="orangeBtn" style="background: #db3652;">自己使用</a></dd>
            </dl>
        </div>
        <!--弹出-->
        <div class="m_popUp" id="m_popUp" style="display:none;" onclick="$('#m_popUp').hide()">
            <div class="m_guide">
                <span></span>
                <div class="m_how">
                    <h4>怎么送朋友？</h4>
                    <p>1: 点击本页面右上角的三个点的图标</p>
                    <p>2: 选择[发送给朋友]</p>
                    <p>3: 将优惠卷转送给好友，该好友成为您的下线，他成功参与云购后，您可获得好友消费返利积分奖励</p>
                </div>
            </div>
        </div>
    {elseif $op=='toshare'}
        <div class="shareCon">
            <div class="m_banner"></div>
            <dl>
                <dt>恭喜获得朋友赠送优惠卷<font color="red"><b>"{$num}"</b></font>张</dt>
                <dt>点击<font color="red"><b>"自己使用"</b></font>,将弹出的二维码展示给核销工作人员，扫码后为你的账户充值相应的夺宝币。</dt>
                <dd onclick="$('#m_popUp').show()"><a id="btnShare" href="javascript:;" class="orangeBtn" style="background: #db3652;">转送给好友</a></dd>
                 <dd  id="check"><a href="javascript:;" class="orangeBtn" style="background: #db3652;">立即使用</a></dd>
            </dl>
        </div>
        <!--弹出-->
        <div class="m_popUp" id="m_popUp" style="display:none;" onclick="$('#m_popUp').hide()">
            <div class="m_guide">
                <span></span>
                <div class="m_how">
                    <h4>怎么送朋友？</h4>
                    <p>1: 点击本页面右上角的三个点的图标</p>
                    <p>2: 选择[发送给朋友]</p>
                    <p>3: 将优惠卷转送给好友，该好友成为您的下线，他成功参与云购后，您可获得好友消费返利积分奖励</p>
                </div>
            </div>
        </div>
    {elseif $op=='sendto'}
    <input type="hidden" name="sendnum" id="sendnum" value="{$sendnum}" />
        <div class="shareCon">
            <dl>
                <dt>您将赠送优惠卷<font color="red"><b>"{$sendnum}"</b></font>张给你的好友。</dt>
                <dt>点击<font color="red"><b>"右上角"</b></font>,将此页面分享给你的好友即可,每种优惠卷只可赠送一次。</dt>
            </dl>
        </div>
    {/if}
<script>
function sendto(){
	var num = document.getElementById("num").value;
	location.href="{php echo $this->createMobileUrl('sharecredit',array('op'=>'sendto','recordid'=>$recordid,'coupon_number'=>$r['coupon_number']))}&sendnum="+num;
}
{if $op=='sendto'}
	wx.ready(function (){
	var sendnum = document.getElementById("sendnum").value;
	var shareData = {
		title: "我的优惠券",
		desc: "快来{php echo $this->module['config']['share_title']}，优惠多多,快来加入吧",
		link: "{$_W['siteroot']}app/{php echo str_replace('./','',$this->createMobileUrl('sharecredit', array('op'=>'toshare','recordid'=>$recordid,'coupon_number'=>$r['coupon_number'])))}&num="+sendnum,
		imgUrl: "{WELIAM_INDIANA_STATIC}/image/youhui.png",
	};
//分享朋友
	wx.onMenuShareAppMessage({
	    title: shareData.title,
	  	desc: shareData.desc,
	  	link: shareData.link,
	  	imgUrl:shareData.imgUrl,
	  	trigger: function (res) {
	  	},
	  	success: function (res) {
	  		alert('分享成功！');
            location.href='{php echo $this->createMobileUrl('credit');}';
	  	},
	  	cancel: function (res) {
	  	},
	  	fail: function (res) {
	    	alert(JSON.stringify(res));
	  	}
	});
//朋友圈
	wx.onMenuShareTimeline({
	  	title: shareData.title,
	  	link: shareData.link,
	  	imgUrl:shareData.imgUrl,
	  	trigger: function (res) {
	  	},
	  	success: function (res) {
	    	window.location.href =adurl;
	  	},
	  	cancel: function (res) {
	  	},
	  	fail: function (res) {
	    	alert(JSON.stringify(res));
	  	}
	});
});
 {/if}
</script>
<script type="text/jscript">
	$("#off").bind("click", function(){
		$("#checkqrode").removeClass("lockDiv");
		$("#checkalert").hide();
	});
  $("#check").bind("click", function(){
		$("#checkalert").show();
		$("#checkqrode").addClass("lockDiv");
	});
</script>
<script>
	function inputnum(){
		var num = document.getElementById("num").value;
		var shengyu = $('#couponnum').val();
			if(!isNaN(num)){
				if(num<=0){
					num=1;
					tip("送0个有意思吗？",true);
					return false;
				}
				if(shengyu<num){
					$('#num').val(shengyu);
					num = shengyu;
					tip("兄弟,你没有那么多优惠卷!",true);
					
				}
			}else{
				tip("输入的是什么鬼？",true);
				$('#num').val(1);
				num=1;
			}
	}
	$("#up").bind('click',function(){
		var num = $('#num').val();
			num = parseInt(num);
		var shengyu = $('#couponnum').val();
		if(shengyu<=num){
			tip("兄弟,你没有那么多!",true);
			return false;
		}
		num =  parseInt(num) + 1; 
		$('#num').val(num);
	});
	$("#down").bind('click',function(){
		var num = $('#num').val();
		num =  parseInt(num) - 1; 
		if(num<=0){
			num=1;
			tip("送0个有意思吗？",true);
			return false;
		}
		$('#num').val(num);
	});
</script>
{template 'common_message'}
</body></html>